Skip to content

Include production names in unexpected token errors - #487

Open
Boulea7 wants to merge 1 commit into
alecthomas:masterfrom
Boulea7:fix/unexpected-token-production-419
Open

Boulea7 wants to merge 1 commit into
alecthomas:masterfrom
Boulea7:fix/unexpected-token-production-419

Conversation

@Boulea7

@Boulea7 Boulea7 commented Oct 5, 2026

Copy link
Copy Markdown

When multiple productions expect the same token, the returned error does not say which production failed. Prefix errors created by Participle with that production's name (Date: unexpected token ...) and preserve the name when backtracking selects a cached error. Custom errors keep their existing behavior; anonymous productions and plain trailing-input errors remain unnamed.

Closes #419.

Tests cover shared terminators, cached/tied errors, root productions, custom errors, and concurrent parsing. With Go 1.26.3, root/example tests and root race tests pass. Local golangci-lint 2.13.1 passes; the repository-pinned 2.12.2 was not run.

On amd64, UnexpectedTokenError grows by 16 bytes. Go 1.26.3 benchmarks show unchanged EBNF B/op and allocs/op; Issue143 uses 1,280 more B/op (2.07%) with unchanged allocs/op. Timing samples are inconclusive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is it possible to get a report on which production was being handled when an error arose?

1 participant